/*
 * ttbqt - A teletekst browser
 * http://code.google.com/p/ttbqt
 * Copyright (C) 2011, Kevin van der Vlist
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include "Factory.h"
#include "../Teletext.h"
// All Teletext factories
#include "../BBC1Teletext.h"
#include "../BBC2Teletext.h"
#include "../NOSTeletext.h"
#include "../OmroepBrabantTeletext.h"
#include "../RTL4Teletext.h"
#include "../RTL5Teletext.h"
#include "../RTL7Teletext.h"
#include "../RTL8Teletext.h"
#include "../RTVNoordHollandTeletext.h"
#include "../RTVNoordTeletext.h"
#include "../RTVOostTeletext.h"
#include "../RTVRijnmondTeletext.h"
#include "../RTVWestTeletext.h"
#include "../VRTTeletext.h"

/**
 * \class Factory
 *
 * \short Generic Factory
 *
 * Provide Teletext's
 */

/**
 * \short Constructor of the Factory class
 *
 * Initialise the factory
 */

Factory::Factory(PageInfo *p) {
  funcmap[BBC1Teletext::TEXTNAME] = dynamic_cast<Teletext*>(new BBC1Teletext(p));
  funcmap[BBC2Teletext::TEXTNAME] = dynamic_cast<Teletext*>(new BBC2Teletext(p));
  funcmap[NOSTeletext::TEXTNAME] = dynamic_cast<Teletext*>(new NOSTeletext(p));
  funcmap[OmroepBrabantTeletext::TEXTNAME] = dynamic_cast<Teletext*>(new OmroepBrabantTeletext(p));
  funcmap[RTL4Teletext::TEXTNAME] = dynamic_cast<Teletext*>(new RTL4Teletext(p));
  funcmap[RTL5Teletext::TEXTNAME] = dynamic_cast<Teletext*>(new RTL5Teletext(p));
  funcmap[RTL7Teletext::TEXTNAME] = dynamic_cast<Teletext*>(new RTL7Teletext(p));
  funcmap[RTL8Teletext::TEXTNAME] = dynamic_cast<Teletext*>(new RTL8Teletext(p));
  funcmap[RTVNoordHollandTeletext::TEXTNAME] = dynamic_cast<Teletext*>(new RTVNoordHollandTeletext(p));
  funcmap[RTVNoordTeletext::TEXTNAME] = dynamic_cast<Teletext*>(new RTVNoordTeletext(p));
  funcmap[RTVOostTeletext::TEXTNAME] = dynamic_cast<Teletext*>(new RTVOostTeletext(p));
  funcmap[RTVRijnmondTeletext::TEXTNAME] = dynamic_cast<Teletext*>(new RTVRijnmondTeletext(p));
  funcmap[RTVWestTeletext::TEXTNAME] = dynamic_cast<Teletext*>(new RTVWestTeletext(p));
  funcmap[VRTTeletext::TEXTNAME] = dynamic_cast<Teletext*>(new VRTTeletext(p));
}

/**
 * \short Factory destructor
 *
 * Total Extermination
 */

Factory::~Factory() {

}

/**
 *
 */

Teletext *Factory::getTeletextChannel(const QString &name) {
  return funcmap[name];
}

/**
 * \short Return the channel map.
 * 
 * \return std::map with all channels 
 *
 * Return the complete channel map.
 */

std::map<QString, Teletext *> *Factory::getChannelMap() {
  return &funcmap;
}
